from django.contrib import admin
from Healths.models import HealthInfoModel, LifeInfoModel, HealthDiseaseModel, LifeDiseaseModel


# 注册模型类
# 自定义管理页面

# 自定义外键关联模型类
# admin.TabularInline  让外键对应的数据   横向排列
# admin.StackedInline  让外键对应的数据   垂直纵向排列
class HealthDiseaseInLine(admin.TabularInline):
    model = HealthDiseaseModel
    fields = ['id', 'name', 'orders']


class LifeDiseaseInLine(admin.TabularInline):
    model = LifeDiseaseModel
    fields = ['id', 'name', 'orders']


class HealthInfoModelAdmin(admin.ModelAdmin):
    list_display = ['id', 'title', 'author', 'create_date', 'is_pass', 'health_cover_small']
    ordering = ['id']
    search_fields = ['title']
    list_filter = ['is_pass']


class LifeInfoModelAdmin(admin.ModelAdmin):
    list_display = ['id', 'title', 'author', 'create_date', 'is_pass', 'life_cover_small']
    ordering = ['id']
    search_fields = ['title']
    list_filter = ['is_pass']


admin.site.register(HealthInfoModel, HealthInfoModelAdmin)
admin.site.register(LifeInfoModel, LifeInfoModelAdmin)
